<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引入vue -->
     <script src="js/vue.js"></script>
     <!-- 引入elementui -->
      <!-- 样式 -->
    <link rel="stylesheet" href="element-ui-2.13.0/lib//theme-chalk/index.css">   
       <!-- 组件库 -->
    <script src="element-ui-2.13.0/lib/index.js"></script>    
</head>
<body>
    <div id="app">
        
        <!-- @click="dialogVisible = true" 绑定单击事件，点击将 dialogVisible设置为true-->
        <el-button type="text" @click="dialogVisible = true">点击打开 Dialog</el-button>


        <!--
            title="温馨提示" 标题
             :visible.sync="dialogVisible" 控制对话框的显示和隐藏
              width="50%" 对话框的宽度
             :before-close="handleClose" 关闭对话框之前执行的回调函数
        -->
        <el-dialog
          title="温馨提示"
          :visible.sync="dialogVisible"
          width="50%"
          :before-close="handleClose">
          <span>这是一段信息</span>
          <span slot="footer" class="dialog-footer">
            <!-- 点击取消和确定都是将对话框设置为隐藏 -->
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
          </span>
        </el-dialog>
         
        
      </div>
</body>
</html>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                dialogVisible: false
            };
        },
        methods: {


            handleClose(done) {
                //确认框
                this.$confirm('确认关闭？')
                .then(_ => {
                    //done 用于关闭 Dialog
                    done();
                })
                .catch(_ => {
                    console.log(1);
                    this.dialogVisible = false
                });
            }
        }
    })
</script>
